package sk.sigp.aobot.swinggui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;

import sk.sigp.aobot.Colors;

class GroupRenderer extends DefaultListCellRenderer {

	private static final long serialVersionUID = 1L;

	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		JLabel l = new JLabel();
		if (value instanceof String) {
			String s = (String) value;
			l.setText(s);
			l.setForeground(Colors.FOREGROUND);
			if (isSelected) {
				l.setOpaque(true);
				l.setBackground(Color.GRAY);
			}
			Font f = new Font(l.getFont().getName(), 0, l.getFont()
					.getSize());
			l.setFont(f);
		}
		return l;
	}

}